package com.zy.qudadid.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.ReportTitle;

import java.util.ArrayList;

/**
 * Created by liuchao on 2016/12/24.
 */

public class ReportTitleAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<ReportTitle> list;

    public ReportTitleAdapter(Context mContext, ArrayList<ReportTitle> list) {
        this.mContext = mContext;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;

        if(convertView!=null){
            view = convertView;
        }else{
            view = LayoutInflater.from(mContext).inflate(R.layout.dialog_listview_item,parent,false);
        }

        ViewHolder holder = (ViewHolder) view.getTag();

        if(holder == null){
            holder = new ViewHolder();

            holder.txtName = (TextView) view.findViewById(R.id.txtName);

            view.setTag(holder);
        }

        ReportTitle item = list.get(position);

        holder.txtName.setText(item.getTitle());

        return view;
    }

    class ViewHolder{
        TextView txtName;
    }
}
